package com.oocl.main;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.oocl.pojo.Book;
import com.oocl.ptp.Consumer;
import com.oocl.sender.BookJsonSender;
import com.oocl.util.BatchUtil;

/**
 * BookJsonSender根据booklist长发送book信息进入队列
 * Consumer调用start方法，监听队列，消费消息并插入DB
 * @author ZENGBR
 *
 */
public class Entrance {

	public static void main(String[] args) throws Exception {
		Book b = new Book(null, "Java", new Date(), 325.54, false,
				"Mike");
		List<Book> books = new ArrayList<Book>();
		for (int i = 0; i < 100; i++) {
			books.add(b);
		}
		BatchUtil.batchWrite(books);
		List<Book> bookList = BatchUtil.batchRead(); 
		BookJsonSender jsender = new BookJsonSender(bookList,"bryce");
		jsender.sendJsonToQueue();
		Consumer consumer = new Consumer("bryce");
		consumer.start();
		
	}
}
